package mn.idax.exchange.otc.service;

import mn.idax.exchange.otc.domain.*;
import mn.idax.exchange.otc.entity.OTCAdWay;
import mn.idax.exchange.otc.entity.OTCAds;
import mn.idax.exchange.otc.exception.IdaxException;
import mn.idax.exchange.otc.vo.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @Auther: dison
 * @Date: 2018/7/30 16:41
 * @Description: 广告列表
 */
public interface OTCAdsService {

    int insertSelective(OTCAds record);

    void addOTCAds(OTCAds record, List<OTCAdWay> otcAdWayList) throws IdaxException;

    /**
     * 功能描述:
     * 判断发布广告限制（一个人一个币种买卖只能发布一个在线广告）
     *
     * @param:
     * @return:
     * @auther: dison
     * @date: 2018/10/10 13:12
     */
    boolean verifyPublishAdvertising(Integer userId, Integer coinId, Integer type);

    int updateOTCAds(OTCAds record, List<OTCAdWay> otcAdWayList);

    OTCAds selectByPrimaryKey(Integer id);

    int updateOTCAdsStateById(OTCAds record);

    int expireBatchOTCAdsState(Map<String, Object> map);

    AccountDTO selectAvailableAmountByUserIdAndCoinId(AccountDTO accountDTO);

    ADShowResultDTO getADPage(OTCAdPageDTO otcAdPageDTO);

    ADShowResultDTO getMyADList(OTCMyAdPageDTO otcMyAdPageDTO) throws Exception;

    int updateTradenumberToOTCAds(OTCAds criteriaAds, Integer oldTradenumber);

    BigDecimal getMaxPrice(String pairname);

    BigDecimal getMinPrice(String pairname);

    /**
     * 出售广告  当币种余额低于平台最低限额时  需要更新下架
     *
     * @param otcAutoDownAdDTO
     * @return
     */
    List<OTCAds> getAvailableAmountLessThanLimtList(OTCAutoDownAdDTO otcAutoDownAdDTO);

    /**
     * 下架广告
     *
     * @param otcAutoDownAdDTO
     * @return
     */
    int updateStateOTCAdsById(OTCAutoDownAdDTO otcAutoDownAdDTO);

    /**
     * 查询过期的广告
     *
     * @param map
     * @return
     */
    List<OTCAds> getExpireBatchOTCAdsState(Map<String, Object> map);

    /**
     * @throws
     * @Title: getOtherUserADList
     * @Description: 获取其他用户发布的广告列表
     * @param: @param otcAdvertiserDTO
     * @param: @return
     * @return: ADShowResultDTO
     */
    ADShowResultDTO getOtherUserADList(OTCAdvertiserDTO otcAdvertiserDTO) throws Exception;

    List<ADRecommendListResult> getRecommendAds(RecommendAdsRequest request) throws Exception;

    //v2广告 查询
    List<ADRecommendListResult> getADPageSec(OTCAdPageSecDTO otcAdPageDTO) throws Exception;

    //v2广告 查询
    Integer getADPageTotalSec(OTCAdPageSecDTO otcAdPageDTO);

    List<OTCAds> getMarketMaxPrice(AdMarketPrice adMarketPrice);

    List<OTCAds> getMarketMinPrice(AdMarketPrice adMarketPrice);


    //用户输入的国家和法币是否和支付方式对应
    Boolean payTypeIsMatch(Integer country, String unit, Integer[] trademode);

    /**
     * 浮动广告价格转换
     */
    FloatingPriceDTO floatingAdsPriceConvert(FloatingPriceDTO floatingPrice) throws Exception;

    /**
     * 将广告从内存中移除
     * @param adId
     */
    void removeAdFromMemory(Integer adId,Integer publisherId);

    /**
     * 将广告添加进内存
     * @param adId
     * @throws Exception
     */
    void addAdInMemory(Integer adId) throws Exception;
    /**
     * 查询单个广告信息
     * @param adId
     * @return
     */
    ADRecommendListDTO getAdDetailInfo(Integer adId);

    /**
     * 获取用户在场内被冻结，却在场外发布的广告
     * @return
     */
    List<FrozenUserAdDTO> getFrozenUserPublishAds();

    /**
     * app 广告详情
     * @param otcAds
     * @param userId
     * @return
     */
    MyAdDetailDTO getMyAdDetail(OTCAds otcAds, Integer userId, HttpServletRequest request) throws Exception;

    /**
     * 获取所有发布上架广告的用户id
     * @return
     */
    List<Integer> getAllUpAdPublisherId();

    /**
     * 获取上架的广告总数
     * @param userId
     * @return
     */
    Integer getCountOfUserUpAd(Integer userId);

    /**
     * 计算加权系数
     * @return
     */
    void getUserProportion();
}
